function toLogin() {
    var userName = $("#userName1").val();
    var pwd = $("#userPwd").val();


    if(isEmpty(userName)){
        alert("用户名不能为空！");
        return;
    }
    if(isEmpty(pwd)){
        alert("密码不能为空");
        return;
    }

    var user={};
    user.userName = userName;
    user.pwd = pwd;

    $.ajax({
        type:"post",
        url:"login",
        data:user,
        datatype:"json",
        success:function (data) {
            /**
             *
             * 存入cookie
             */
            var result = data.result;
            if(data.code==200){
                $.cookie("user",result);
                $.cookie("userIdStr",result.idStr);
                window.location.href="main";
            }else{
                alert(data.msg);
            }
        }
    })
}
function openRegisterDialog() {
    $("#dlg").dialog("open").dialog("setTitle","新用户注册");
}
function closeRegisterDialog() {
    $("#dlg").dialog("close");
}
function toRegister() {
    var username = $("#userName").val();
    var confirmPassword = $("#confirmPassword").val();
    var pwd = $("#password").val();
    var mobile = $("#mobile").val();

    if(isEmpty(username)){
        alert("用户名不能为空");
        return;
    }
    if(isEmpty(mobile)){
        alert("手机号不能为空");
        return;
    }
    if(mobile.length>=11){
        alert("手机号格式不正确");
        return;
    }
    if(isEmpty(pwd)){
        alert("密码不能为空");
        return;
    }
    if(isEmpty(confirmPassword)){
        alert("确认密码不能为空");
        return;
    }
    if(pwd!=confirmPassword){
        alert("两次输入密码不一致！");
        return;
    }
    $("#fm").form("submit",{
        url:ctx+"/user/toRegister",
        onSubmit:function () {
            return $(this).form("validate");
        },
        success:function (data) {
            data=JSON.parse(data);
            if(data.code==200){
                $.messager.alert("来自cuixk","注册成功！","info");
                window.location.href="index";
            }else{
                alert(data.msg);
            }
        }
    })
}